package cn.edu.ctbu.finaltest.service.TeacherTeachingService.impl;

import cn.edu.ctbu.finaltest.exception.REnum;
import cn.edu.ctbu.finaltest.service.TeacherTeachingService.TeacherTeachingService;
import cn.edu.ctbu.finaltest.vo.R;
import cn.edu.ctbu.finaltest.vo.TeacherTeaching;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class TeacherTeachingImplService implements TeacherTeachingService {

    public R<List<TeacherTeaching>> findByCnoLike(String cno, List<TeacherTeaching> TTList){
        List <TeacherTeaching> teacherTeachings = new ArrayList<>();
        R<List<TeacherTeaching>> RTeacherTeachings = new R<>();
        for (int i = 0;i < TTList.size();i++){
            if (TTList.get(i).getCno().indexOf(cno) >= 0){
                teacherTeachings.add(TTList.get(i));
            }
        }
        RTeacherTeachings.setData(teacherTeachings);
        RTeacherTeachings.setMsg(REnum.SUCCESS.getMsg());
        RTeacherTeachings.setCode(REnum.SUCCESS.getCode());
        return RTeacherTeachings;
    }

    public R<List<TeacherTeaching>> findByCnameLike(String cname,List<TeacherTeaching> TTList){
        List <TeacherTeaching> teacherTeachings = new ArrayList<>();
        R<List<TeacherTeaching>> RTeacherTeachings = new R<>();
        for (int i = 0;i < TTList.size();i++){
            if (TTList.get(i).getCname().indexOf(cname) >= 0){
                teacherTeachings.add(TTList.get(i));
            }
        }
        RTeacherTeachings.setData(teacherTeachings);
        RTeacherTeachings.setMsg(REnum.SUCCESS.getMsg());
        RTeacherTeachings.setCode(REnum.SUCCESS.getCode());
        return RTeacherTeachings;
    }


    public R<List<TeacherTeaching>> findBySnoLike(String sno,List<TeacherTeaching> TTList){
        List <TeacherTeaching> teacherTeachings = new ArrayList<>();
        R<List<TeacherTeaching>> RTeacherTeachings = new R<>();
        for (int i = 0;i < TTList.size();i++){
            if (TTList.get(i).getSno().indexOf(sno) >= 0){
                teacherTeachings.add(TTList.get(i));
            }
        }
        RTeacherTeachings.setData(teacherTeachings);
        RTeacherTeachings.setMsg(REnum.SUCCESS.getMsg());
        RTeacherTeachings.setCode(REnum.SUCCESS.getCode());
        return RTeacherTeachings;
    }

    public R<List<TeacherTeaching>> findBySnameLike(String sname,List<TeacherTeaching> TTList){
        List <TeacherTeaching> teacherTeachings = new ArrayList<>();
        R<List<TeacherTeaching>> RTeacherTeachings = new R<>();
        for (int i = 0;i < TTList.size();i++){
            if (TTList.get(i).getSname().indexOf(sname) >= 0){
                teacherTeachings.add(TTList.get(i));
            }
        }
        RTeacherTeachings.setData(teacherTeachings);
        RTeacherTeachings.setMsg(REnum.SUCCESS.getMsg());
        RTeacherTeachings.setCode(REnum.SUCCESS.getCode());
        return RTeacherTeachings;
    }



    public R<List<TeacherTeaching>> findByCno(String cno,List<TeacherTeaching> TTList){
        List <TeacherTeaching> teacherTeachings = new ArrayList<>();
        R<List<TeacherTeaching>> RTeacherTeachings = new R<>();
        for (int i = 0;i < TTList.size();i++){
            if (TTList.get(i).getCno().equals(cno)){
                teacherTeachings.add(TTList.get(i));
            }
        }
        RTeacherTeachings.setData(teacherTeachings);
        RTeacherTeachings.setMsg(REnum.SUCCESS.getMsg());
        RTeacherTeachings.setCode(REnum.SUCCESS.getCode());
        return RTeacherTeachings;
    }

    public R<List<TeacherTeaching>> findByCname(String cname,List<TeacherTeaching> TTList){
        List <TeacherTeaching> teacherTeachings = new ArrayList<>();
        R<List<TeacherTeaching>> RTeacherTeachings = new R<>();
        for (int i = 0;i < TTList.size();i++){
            if (TTList.get(i).getCname().equals(cname)){
                teacherTeachings.add(TTList.get(i));
            }
        }
        RTeacherTeachings.setData(teacherTeachings);
        RTeacherTeachings.setMsg(REnum.SUCCESS.getMsg());
        RTeacherTeachings.setCode(REnum.SUCCESS.getCode());
        return RTeacherTeachings;
    }


    public R<List<TeacherTeaching>> findBySno(String sno,List<TeacherTeaching> TTList){
        List <TeacherTeaching> teacherTeachings = new ArrayList<>();
        R<List<TeacherTeaching>> RTeacherTeachings = new R<>();
        for (int i = 0;i < TTList.size();i++){
            if (TTList.get(i).getSno().equals(sno)){
                teacherTeachings.add(TTList.get(i));
            }
        }
        RTeacherTeachings.setData(teacherTeachings);
        RTeacherTeachings.setMsg(REnum.SUCCESS.getMsg());
        RTeacherTeachings.setCode(REnum.SUCCESS.getCode());
        return RTeacherTeachings;
    }

    public R<List<TeacherTeaching>> findBySname(String sname,List<TeacherTeaching> TTList){
        List <TeacherTeaching> teacherTeachings = new ArrayList<>();
        R<List<TeacherTeaching>> RTeacherTeachings = new R<>();
        for (int i = 0;i < TTList.size();i++){
            if (TTList.get(i).getSname().equals(sname)){
                teacherTeachings.add(TTList.get(i));
            }
        }
        RTeacherTeachings.setData(teacherTeachings);
        RTeacherTeachings.setMsg(REnum.SUCCESS.getMsg());
        RTeacherTeachings.setCode(REnum.SUCCESS.getCode());
        return RTeacherTeachings;
    }


}
